package edu.gdkm.dao;

import edu.gdkm.pojo.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface TeacherXml {

    // 插入教师信息
    @Insert("INSERT INTO teacher(name, age, mobile, course) VALUES(#{name}, #{age}, #{mobile}, #{course})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertTeacher(Teacher teacher);

    // 根据ID删除教师
    @Delete("DELETE FROM teacher WHERE id = #{id}")
    int deleteTeacherById(Integer id);

    // 更新教师信息
    @Update("UPDATE teacher SET name=#{name}, age=#{age}, mobile=#{mobile}, course=#{course} WHERE id=#{id}")
    int updateTeacher(Teacher teacher);

    // 根据ID查询教师
    @Select("SELECT * FROM teacher WHERE id = #{id}")
    Teacher getTeacherById(Integer id);

    // 查询所有教师
    @Select("SELECT * FROM teacher")
    List<Teacher> getAllTeachers();

    // 根据课程查询教师
    @Select("SELECT * FROM teacher WHERE course = #{course}")
    List<Teacher> getTeachersByCourse(String course);
}